package task.snake.model;

import java.awt.Point;

import task.snake.model.Snake.Eat;

public class BlueFrog extends Frog {
	private final String TYPE_OF_FROG = "Blue";
	private final int LIFE_TIME = 9;
	private int lifeTime = 0;

	/**
	 * Initializes a newly created Frog object.
	 * 
	 * @param p position on play field
	 * @param sm snake model object
	 */
	public BlueFrog(Point p, SnakeModel sm) {
		super(p, sm);
	}

	/**
	 * Method returns type of frog.
	 */
	@Override
	public String getTypeOfFrog() {
		return TYPE_OF_FROG;
	}

	/**
	 * Describe situation when red frog clashed by the snake.
	 */
	@Override
	public boolean onClash(Snake snake) {
		if (snake.getHeadLocation().equals(this.getHeadLocation())) {
			// tells snake that it has to grow up while net movement
			snake.setEat(Eat.BLUE_FROG);
			// kills frog and create new one
			reincarnateFrog();
			return true;
		}
		return false;
	}

	public void move() {
		super.move();
		lifeTime++;
		if (lifeTime == LIFE_TIME) {
			lifeTime = 0;
			reincarnateFrog();
		}
	}
}
